import { get, post } from '../request'

const order = {
  // 订单预览
  orderPreview(param) {
    return post(
      '/order/preview',
      param,
    )
  },

  // 直接购买到确认订单
  confirmOrder(param) {
    return post(
      '/order/confirm',
      param,
    )
  },

  // 购物车到确认订单
  confirmOrderFromCart(param) {
    return post(
      '/order/confirm/cart',
      param,
    )
  },

  // 获取用户订单
  getOrderOfUser(status, param) {
    return get(
      `/order/userorder/${status}`,
      param,
    )
  },

  // （批量）支付订单
  payOrders(param) {
    return post(
      '/order/pay',
      param
    )
  },

  // （批量）删除订单
  deleteOrder(param) {
    return post(
      '/order/delete',
      param
    )
  },

  // 确认收货
  confirmReceive(orderId) {
    return post(
      `/order/receipt/${orderId}`
    )
  },

  // 撤销订单
  cancelOrder(orderId) {
    return post(
      `/order/quash/${orderId}`
    )
  },

  // 用户申请退货
  returnOrderRequest(param) {
    return post(
      '/order/request/return',
      param
    )
  },

  // 商户处理退款申请
  processReturnOrderRequest(param) {
    return post(
      '/order/request/return/process',
      param
    )
  },

  // 获取用户退货申请
  getReturnOrderRequestOfUser(userId, param) {
    return get(
      `/order/request/return/${userId}`,
      param
    )
  },

  // 获取商店退货申请信息
  getReturnOrderRequestOfStore(storeId, param) {
    return get(
      `/order/request/return/store/${storeId}`,
      param
    )
  }
}

export default order;
